package org.tuoren.java.ai.langchain4j.config;

import dev.langchain4j.memory.chat.ChatMemoryProvider;
import dev.langchain4j.memory.chat.MessageWindowChatMemory;
import dev.langchain4j.store.memory.chat.InMemoryChatMemoryStore;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.tuoren.java.ai.langchain4j.store.MongoChatMemoryStore;

@Configuration
public class SeparateChatAssistantConfig {
    @Autowired
    private MongoChatMemoryStore mongoChatMemoryStore;
    @Bean
    ChatMemoryProvider chatMemoryProvider() {
        return memoryId -> MessageWindowChatMemory.builder()
                .id(memoryId)//设置记忆聊天隔离ID
                .maxMessages(10)//设置聊天记忆记录的message数量
                .chatMemoryStore(mongoChatMemoryStore)//设置本地聊天记忆存储对象
                .build();
    }
}
